<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    const search = window.location.href;
    
    if(search.includes('code=')) {
      const code = window.location.href.substring(6).split('&')[0];
      localStorage.setItem('code', code);
    } else {
        // 获取微信用户code
      function wxEmpower(path = 'print/index.html') {
        const { data } = JSON.parse(window.name);

        let appid = data.appId;
        let base_url = data.base_url;
        console.log('oooo')
        let url = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${appid}&redirect_uri=${encodeURIComponent(base_url + path)}&response_type=code&scope=snsapi_base&state=STATE&connect_redirect=1#wechat_redirect`;
        //  页面跳转
        location.href = url;
      }
    }
  </script>
</body>

</html>